<?php
/**
 * session initialization
 */
session_start();
session_regenerate_id();
session_cache_expire(900);
/**
 * get config.php file
 */
try {
	
	if(file_exists("./configs/configuration.php")){

		require_once './configs/configuration.php';
	
	}
	
	else {
		
		throw new Exception("Framework can't load file: '<strong>./configs/configurstion.php</strong>'!!!");
		
	}
	
}
catch(Exception $e){
	
	echo $e->getMessage();
	
}

function __autoload($className){
	
	try {
		
		if(file_exists("./core/controllers/autoloader.php")){
			
			require_once './core/controllers/autoloader.php';
			
			$autoloader = new Core_Controller_Autoloader();
			$autoloader->loadFile($className);
		
		}
		else {
			
			throw new Exception("Framework could not load file '<string>./core/controllers/autoloader.php</string>");
			
		}
	}
	catch(Exception $e){
		echo $e->getMessage();
	}
	
}

/**
 * security all arrays
 */
try {
	
	if(file_exists("./core/data/secure")){
		
		require_once './core/data/secure';
		
		$secure = new Core_Data_Secure();
		
		if(get_magic_quotes_gpc()){
			
			$_GET = $secure->stripSlashes($_GET);
			$_POST = $secure->stripSlashes($_POST);
			$_COOKIE = $secure->stripSlashes($_COOKIE);
			$_REQUEST = $secure->stripSlashes($_REQUEST);
			
		}
	}
	
}
catch(Exception $e){
	
	echo $e->getMessage();
	
}

$request = $_SERVER['QUERY_STRING'];
$poatVars = array();
$postVars = $_POST;
try {
	
	if(file_exists("./core/controllers/controllerloader.php")){

		require_once './core/controllers/controllerloader.php';
		$controllerLoader = new Core_Controller_Controllerloader();
		$controllerLoader->getController($request, $postVars);
	}
	
	else {
		
		throw new Exception("Framework can't load file: '<strong>./core/controllers/controllerloader.php</strong>!!!");
		
	}
}
catch(Exception $e){
	echo $e->getMessage();
}